import { StationNetwork } from "GameLoop/Path/StationNetwork";

export class GlobalEventCheck 
{
    // 这里需要优化把自己的房间记录下来。用作对比.而不是每次都来重新遍历判断
    public static checkExpireRooms(worldgetter:WorldGetter,  emitter:TEventEmitter<TEventTypes>)
    {
        if(!global.canExecute(10000))
        {
            return 
        }
        // const rooms = Object.keys(Memory.rooms);
        for(let i=0;i< Memory.myrooms.length;i++)
        {
            const k = Memory.myrooms[i];
            if(Memory.rooms[k])
            {
                if(!Memory.rooms[k].config)
                {
                    //delete Memory.rooms[k];
                    continue;
                }
                if(!Game.rooms[k] && Memory.rooms[k].config.type ==1)
                {
                    emitter(Game.shard.name,"LostRoomEvent",{
                        region:Game.shard.name,
                        room:k,
                        type:1,
                    })
                }
            }
            
        }
    }

    public static checkResourceBlance(worldgetter:WorldGetter,  emitter:TEventEmitter<TEventTypes>)
    {
        if(global.canExecute(2000))
        {
            emitter(Game.shard.name,"ResourceBlance",{
                type:1,
                region:Game.shard.name,
                room:""
            })
        }

        if(global.canExecute(1510))
        {
            emitter(Game.shard.name,"FactoryProduce",{
                type:1,
                region:Game.shard.name,
                room:""
            })
        }
    }
}